home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / tab100 / tab.bas < prev    next >
Encoding:
BASIC Source File  |  1995-09-06  |  20.2 KB  |  795 lines

  1.  
  2. Sub TestForJack (Pv As Integer, Vp As String, Flag As Integer)
  3.         If Pv = 12 Then
  4.            Vp = "Y"
  5.         End If
  6. End Sub
  7.  
  8. Sub TestEqualRank (Pv As Integer, Vp As String, RCds As Integer)
  9.     Dim i As Integer
  10.  
  11.     For i = 1 To TableNo
  12.         If Pv = TableArray(i) Then
  13.             Vp = "Y"
  14.             NewTableArray(i) = 0
  15.             RCds = RCds - 1
  16.         End If
  17.     Next i
  18.     
  19. End Sub
  20.  
  21. Sub TestEqualValue (Pv As Integer, Vp As String, RCds As Integer)
  22.     
  23.     Dim MatchFound As Integer
  24.     Dim j As Integer
  25.     Dim k As Integer
  26.     
  27.     For j = 1 To TableNo - 1
  28.         For k = j + 1 To TableNo
  29.             If Pv = TableArray(j) + TableArray(k) Then
  30.                 Vp = "Y"
  31.                 NewTableArray(j) = 0
  32.                 NewTableArray(k) = 0
  33.                 RCds = RCds - 2
  34.                 Exit Sub
  35.             End If
  36.             TestAsAces TableArray(j), TableArray(k), Pv, RCds, Vp, MatchFound
  37.             If MatchFound = TRUE Then
  38.                 NewTableArray(j) = 0
  39.                 NewTableArray(k) = 0
  40.                 RCds = RCds - 2
  41.                 Exit Sub
  42.             End If
  43.         Next k
  44.     Next j
  45.     
  46. End Sub
  47.  
  48. Sub TestForTypeOfPlay (Pv As Integer, Vp As String, Pos As Integer, RCds As Integer, TyOP As Integer)
  49.         
  50.     Dim i As Integer
  51.     Dim SumRCds As Integer
  52.  
  53.     SumRCds = 0
  54.  
  55.     If Pv = 12 Then
  56.         TyOP = JACK
  57.         Exit Sub
  58.     End If
  59.  
  60.     If RCds = 0 Then
  61.         TyOP = TABLENETTE
  62.         Exit Sub
  63.     End If
  64.  
  65.     For i = 1 To TableNo
  66.         SumRCds = SumRCds + NewTableArray(i)
  67.     Next i
  68.  
  69.     If SumRCds = 12 Then
  70.         TyOP = TOTAL_12
  71.         Exit Sub
  72.     End If
  73.  
  74.     If RCds = 1 Then
  75.         If SumRCds > 11 Then
  76.             SumRCds = SumRCds - 1
  77.         End If
  78.         If SumRCds = 11 Then
  79.             SumRCds = 1
  80.         End If
  81.         Select Case EqualRankGone(SumRCds)
  82.             Case 3
  83.                 TyOP = ONECARD_NOEQUAL
  84.             Case 2
  85.                 TyOP = ONECARD_ONEEQUAL
  86.             Case 1, 0
  87.                 Vp = ""
  88.                 TyOP = REJECTED_MOVE
  89.         End Select
  90.         Exit Sub
  91.     End If
  92.             
  93.  
  94.     If RCds >= 3 Then
  95.         TyOP = THREECARDS_PLUS
  96.     Else
  97.         TyOP = TWOCARDS
  98.     End If
  99.             
  100. End Sub
  101.  
  102. Sub AddToCardsTotal (Count As Integer)
  103.     If GameSwitch = PLAYER_MOVE Then
  104.         PlayerCardsNo = PlayerCardsNo + Count
  105.     Else
  106.         ComputerCardsNo = ComputerCardsNo + Count
  107.     End If
  108. End Sub
  109.  
  110. Sub AddToEqualRank (C1 As Integer)
  111.     EqualRankGone(C1) = EqualRankGone(C1) + 1
  112. End Sub
  113.  
  114. Sub AddToScore (C1 As Integer)
  115.  
  116.     Dim Score As Integer
  117.     If GameSwitch = PLAYERMOVE Then
  118.         Score = PSCore
  119.         PickUpSwitch = PLAYER
  120.     Else
  121.         Score = CSCore
  122.         PickUpSwitch = COMPUTER
  123.     End If
  124.  
  125.     Select Case C1
  126.         Case 1, 14, 27, 40          'Aces count 1
  127.             Score = Score + 1
  128.         Case 13, 26, 39, 52         'Kings count 1
  129.             Score = Score + 1
  130.         Case 12, 25, 38, 51         'Queens count 1
  131.             Score = Score + 1
  132.         Case 11, 24, 37, 50         'Jacks count 1
  133.             Score = Score + 1
  134.         Case 10, 23, 36             '10s except Diamonds score 1
  135.             Score = Score + 1
  136.         Case 49                     '10 Diamonds scores 2
  137.             Score = Score + 2
  138.         Case 28                     '2 Clubs scores 1
  139.             Score = Score + 1
  140.     End Select
  141.  
  142.     If GameSwitch = PLAYER_MOVE Then
  143.         PSCore = Score
  144.         If Val(Form1.PlayerScore.Caption) <> PSCore Then
  145.             Form1.PlayerScore.Caption = Str$(PSCore)
  146.         End If
  147.     Else
  148.         CSCore = Score
  149.         If Val(Form1.ComputerScore.Caption) <> CSCore Then
  150.             Form1.ComputerScore.Caption = Str$(CSCore)
  151.         End If
  152.     End If
  153.  
  154. End Sub
  155.  
  156. Sub AskForNewGame ()
  157.  
  158.     Dim MsgBoxResponse As Integer
  159.  
  160.     MsgBoxResponse = MsgBox("Do You Wish to Play Again", MBB_YNCAN + MBI_INFO)
  161.     If MsgBoxResponse = MB_YES Then
  162.         NewGame
  163.         FirstDeal
  164.     Else
  165.         End
  166.     End If
  167. End Sub
  168.  
  169. Function BestComputerDiscard ()
  170.     
  171.     Dim i As Integer
  172.     
  173.  
  174.     If TableNo = 0 Then
  175.         DiscardOnZero
  176.     Else
  177.         If TableNo > 0 Then
  178.             DiscardOnOne
  179.         End If
  180.     End If
  181.     
  182.     For i = 1 To 10
  183.         For j = 1 To ComputerNo
  184.                 If TypeOfDiscard(j) = i Then
  185.                     BestComputerDiscard = j
  186.                     Exit Function
  187.                 End If
  188.         Next j
  189.     Next i
  190.     
  191.  
  192. End Function
  193.  
  194. Function BestComputerMove ()
  195.     Dim i As Integer
  196.     Dim j As Integer
  197.  
  198.     Flag = False
  199.     
  200.     For i = 1 To 7
  201.         For j = 1 To ComputerNo
  202.             If ValidPlay(j) = "Y" Then
  203.                 If TypeOfPlay(j) = i Then
  204.                     BestComputerMove = j
  205.                     Flag = True
  206.                     Exit Function
  207.                 End If
  208.             End If
  209.         Next j
  210.     Next i
  211.  
  212. End Function
  213.  
  214. Sub CheckFor27Cards ()
  215.     If PlayerCardsNo > 27 Then
  216.         PSCore = PSCore + 3
  217.         Form1.PlayerScore.Caption = Str$(PSCore)
  218.     End If
  219.     If ComputerCardsNo > 27 Then
  220.         CSCore = CSCore + 3
  221.         Form1.ComputerScore.Caption = Str$(CSCore)
  222.     End If
  223. End Sub
  224.  
  225. Function CheckForWin ()
  226.     
  227.     Flag = False
  228.  
  229.     If Val(Form1.PlayerScore.Caption) > 251 Then
  230.         If Val(Form1.PlayerScore.Caption) > Val(Form1.ComputerScore.Caption) Then
  231.             MsgBox ("Well done you've Won")
  232.             CheckForWin = True
  233.         Else
  234.             MsgBox ("Computer Wins This Game")
  235.             Flag = True
  236.         End If
  237.     Else
  238.         If Val(Form1.ComputerScore.Caption) > 251 Then
  239.             MsgBox ("Computer Wins This Game")
  240.             CheckForWin = True
  241.         End If
  242.     End If
  243.  
  244. End Function
  245.  
  246. Sub CheckTableCards (A() As String, V As Integer, Pos As Integer, VNo As Integer)
  247.  
  248.  
  249.     Dim TableVal As Integer
  250.     Dim FirstCardVal As Integer
  251.     Dim j As Integer
  252.     
  253.  
  254.     TableVal = CardValue(Cards(Val(Form1.Picture1(Pos).Tag)))
  255.     SetNewValue TableVal
  256.     FirstCardVal = TableVal
  257.     
  258.  
  259.  
  260.     For j = Pos + 1 To TableNo
  261.         TableVal = CardValue(Cards(Val(Form1.Picture1(j).Tag)))
  262.         SetNewValue TableVal
  263.         If V = FirstCardVal + TableVal Then
  264.             A(VNo + 1) = Str$(Pos) + "," + Str$(j)
  265.             VNo = VNo + 1
  266.         Else
  267.             CheckAcesAsOne FirstCardVal, TableVal, V, A(), Pos, j, VNo
  268.         End If
  269.     Next j
  270.     
  271. End Sub
  272.  
  273. Sub ClearValidPlays ()
  274.     For i = 1 To 6
  275.         ValidPlay(i) = ""
  276.         TypeOfPlay(i) = 0
  277.     Next i
  278. End Sub
  279.  
  280. Sub DiscardOnOne ()
  281.     
  282.     Dim CompCard As Integer
  283.     Dim TableCard As Integer
  284.     Dim TwoCardVal  As Integer
  285.  
  286.     TableCard = CardValue(Cards(Val(Form1.Picture1(1).Tag)))
  287.     SetNewValue TableCard
  288.     
  289.  
  290.     For i = 1 To ComputerNo
  291.         CompCard = CardValue(Cards(Val(Form1.Picture4(i).Tag)))
  292.         SetNewValue CompCard
  293.  
  294.         If CompCard = TableCard Then
  295.             TypeOfDiscard(i) = 10
  296.         Else
  297.             If CompCard + TableTotal = 12 Then
  298.                 If CompCard <> TableCard Then
  299.                     TypeOfDiscard(i) = 1
  300.                 End If
  301.             Else
  302.                 If CompCard + TableTotal > 14 Then
  303.                     If CompCard <> TableCard Then
  304.                         TypeOfDiscard(i) = 2
  305.                     End If
  306.                 Else
  307.                     Select Case EqualRankGone(CardValue(Cards(Val(Form1.Picture4(i).Tag))))
  308.                         Case 3
  309.                             TypeOfDiscard(i) = 3
  310.                         Case 2
  311.                             If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  312.                                 TypeOfDiscard(i) = 4
  313.                             Else
  314.                                 TypeOfDiscard(i) = 5
  315.                             End If
  316.                         Case 1
  317.                             If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  318.                                 TypeOfDiscard(i) = 6
  319.                             Else
  320.                                 TypeOfDiscard(i) = 7
  321.                             End If
  322.                         Case 0
  323.                             If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  324.                                 TypeOfDiscard(i) = 8
  325.                             Else
  326.                                 TypeOfDiscard(i) = 9
  327.                             End If
  328.                     End Select
  329.                 End If
  330.             End If
  331.         End If
  332.     
  333.  
  334.         Next i
  335. End Sub
  336.  
  337. Sub DiscardOnZero ()
  338.     Dim i As Integer
  339.  
  340.     For i = 1 To ComputerNo
  341.         Select Case EqualRankGone(CardValue(Cards(Val(Form1.Picture4(i).Tag))))
  342.             Case 3
  343.                 TypeOfDiscard(i) = 1
  344.             Case 2
  345.                 If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  346.                     TypeOfDiscard(i) = 2
  347.                 Else
  348.                     TypeOfDiscard(i) = 3
  349.                 End If
  350.             Case 1
  351.                 If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  352.                     TypeOfDiscard(i) = 4
  353.                 Else
  354.                     TypeOfDiscard(i) = 5
  355.                 End If
  356.             Case 0
  357.                 If CardValue(Cards(Val(Form1.Picture4(i).Tag))) < 7 Then
  358.                     TypeOfDiscard(i) = 6
  359.                 Else
  360.                     TypeOfDiscard(i) = 7
  361.                 End If
  362.         End Select
  363.     Next i
  364. End Sub
  365.  
  366. Sub EnableComputerMove ()
  367.     Form1.ComputerMove.Enabled = True
  368.     For i = 1 To 6
  369.         Form1.Picture2(i).Enabled = False
  370.     Next i
  371.     MakeComputerMove
  372. End Sub
  373.  
  374. Sub EnablePlayerMove ()
  375.     Form1.ComputerMove.Enabled = False
  376.     For i = 1 To 6
  377.         Form1.Picture2(i).Enabled = True
  378.     Next i
  379. End Sub
  380.  
  381. Sub JackPlayed ()
  382.     For i = TableNo To 1 Step -1
  383.         AddToScore CardValue(Cards(Val(Form1.Picture1(i).Tag)))
  384.         AddToEqualRank CardValue(Cards(Val(Form1.Picture1(i).Tag)))
  385.         ShiftLeftTable (i)
  386.         AddToCardsTotal (TableNo + 1)
  387.     Next i
  388.     
  389. End Sub
  390.  
  391. Sub LastPickup ()
  392.     If PickUpSwitch = PLAYER Then
  393.         GameSwitch = PLAYER_MOVE
  394.     Else
  395.         GameSwitch = COMPUTER_MOVE
  396.     End If
  397.  
  398.     For i = TableNo To 1 Step -1
  399.         AddToScore CardValue(Cards(Val(Form1.Picture1(i).Tag)))
  400.         ShiftLeftTable (i)
  401.         AddToCardsTotal (TableNo)
  402.     Next i
  403. End Sub
  404.  
  405. Sub LoadSuits ()
  406.     Suits(1) = "Spades"
  407.     Suits(2) = "Hearts"
  408.     Suits(3) = "Clubs"
  409.     Suits(4) = "Diamonds"
  410. End Sub
  411.  
  412. Sub LoadTableArray ()
  413.  
  414.     For i = 1 To TableNo
  415.         TableArray(i) = CardValue(Cards(Val(Form1.Picture1(i).Tag)))
  416.         SetNewValue TableArray(i)
  417.         NewTableArray(i) = TableArray(i)
  418.     Next i
  419. End Sub
  420.  
  421. Sub MakeComputerMove ()
  422.     Dim X As Single
  423.     Dim Y As Single
  424.     Dim GoodMove As Integer
  425.     Dim ValidCard As Integer
  426.     Dim BestCard As Integer
  427.     Dim CurrTime As Double
  428.     Dim StartTime As Double
  429.     ClearValidPlays
  430.     TestPlays
  431.     ValidCard = BestComputerMove()
  432.  
  433.     If ValidCard <> 0 Then
  434.         Form1.Picture5(1).Visible = True
  435.         Form1.Picture5(1).Picture = Form1.Picture4(ValidCard).Picture
  436.         Beep
  437.         CurrTime = TimeValue(Time$)
  438.         StartTime = CurrTime + .0000075
  439.         Do While StartTime > CurrTime
  440.             CurrTime = TimeValue(Time$)
  441.         Loop
  442.         
  443.         MakeMove 1, Form1.Picture4(ValidCard), X, Y
  444.         Form1.Picture5(1).Visible = False
  445.     Else
  446.         BestCard = BestComputerDiscard()
  447.         Form1.Picture5(1).Visible = True
  448.         Form1.Picture5(1).Picture = Form1.Picture4(BestCard).Picture
  449.         Beep
  450.         CurrTime = TimeValue(Time$)
  451.         StartTime = CurrTime + .0000075
  452.         Do While StartTime > CurrTime
  453.             CurrTime = TimeValue(Time$)
  454.         Loop
  455.  
  456.         MakeMove TableNo + 1, Form1.Picture4(BestCard), X, Y
  457.  
  458.         Form1.Picture5(1).Visible = False
  459.     End If
  460.  
  461.  
  462.  
  463.     
  464. End Sub
  465.  
  466. Sub MakeMove (Index As Integer, Source As Control, X As Single, Y As Single)
  467.     Dim HoldNo  As Integer
  468.  
  469. '   1. Players covers any card
  470. '           If Jack all cards removed but
  471. '               no Tablenette Scored
  472. '       check if any 2 or 3 cards = its Value
  473. '       check if Equal Rank cards exists
  474. '       check if all Table cards taken "Tablenette score"
  475. '
  476. '   OR
  477. '
  478. '   2. Player drops card on table (the card back at end)
  479. '       Game adds card to table
  480.  
  481.     HoldNo = TableNo
  482.  
  483.     CalculateTableTotal
  484.  
  485.     If CardValue(Cards(Val(Source.Tag))) = 11 Then
  486.         JackPlayed
  487.         AddToScore CardValue(Cards(Val(Source.Tag)))
  488.         AddToEqualRank CardValue(Cards(Val(Source.Tag)))
  489.         ShiftLeftWho (Source.Index)
  490.         Exit Sub
  491.     End If
  492.         
  493.  
  494.     If Index <= TableNo Then
  495.  
  496.         CheckEqualRank Val(Source.Tag)
  497.         CheckEqualValue Val(Source.Tag)
  498.  
  499.         If TableNo = HoldNo Then
  500.             MsgBox ("No Valid Match with This Card")
  501.             Exit Sub
  502.         Else
  503.             AddToScore CardValue(Cards(Val(Source.Tag)))
  504.             AddToEqualRank CardValue(Cards(Val(Source.Tag)))
  505.             If TableNo = 0 Then
  506.                 ScoreTablenette Val(Source.Tag)
  507.             End If
  508.             ShiftLeftWho (Source.Index)
  509.         End If
  510.  
  511.     Else
  512.         Form1.Picture1(Index + 1).Picture = Form1.Picture1(Index).Picture
  513.         Form1.Picture1(Index).Picture = Source.Picture
  514.         Form1.Picture1(Index).Tag = Source.Tag
  515.         Form1.Picture1(Index + 1).Enabled = True
  516.         Form1.Picture1(Index + 1).Visible = True
  517.         Form1.Picture1(Index + 1).Tag = "End"
  518.         TableNo = Index
  519.         ShiftLeftWho (Source.Index)
  520.     End If
  521.  
  522.     
  523. End Sub
  524.  
  525. Sub NewGame ()
  526.     
  527.     CardNo = 1
  528.     For i = 6 To 12
  529.         Form1.Picture1(i).Visible = False
  530.         Form1.Picture1(i).Enabled = False
  531.     Next i
  532.     CSCore = 0
  533.     PSCore = 0
  534.     Form1.ComputerScore.Caption = Str$(CSCore)
  535.     Form1.PlayerScore.Caption = Str$(PSCore)
  536.     DealSwitch = COMPUTER_DEAL
  537. End Sub
  538.  
  539. Sub ScoreTablenette (C1 As Integer)
  540.  
  541.     Dim PlayVal As Integer
  542.     Dim ComputerVal As Integer
  543.  
  544.     If GameSwitch = PLAYER_MOVE Then
  545.         PlayVal = CardValue(Cards(C1))
  546.         SetNewValue PlayVal
  547.         PSCore = PSCore + TableTotal + PlayVal
  548.         Form1.PlayerScore.Caption = Str$(PSCore)
  549.     Else
  550.         ComputerVal = CardValue(Cards(C1))
  551.         SetNewValue ComputerVal
  552.         CSCore = CSCore + TableTotal + ComputerVal
  553.         Form1.ComputerScore.Caption = Str$(CSCore)
  554.     End If
  555.  
  556. End Sub
  557.  
  558. Sub SetNewValue (Value As Integer)
  559. '   Tablenette has the following Values:-
  560. '   Ace 1 or 11, Jack 12, Queen 14, King 14
  561. '   all other cards are face value.
  562.  
  563.     Select Case Value
  564.         Case 13
  565.             Value = 14
  566.         Case 12
  567.             Value = 13
  568.         Case 11
  569.             Value = 12
  570.         Case 1
  571.             Value = 11
  572.     End Select
  573.     
  574. End Sub
  575.  
  576. Sub ShiftLeft (A() As Integer, First As Integer, Last As Integer)
  577.  
  578. '   Shift the specified region of the array 1 to the left.
  579. '
  580.     ' A() is the array
  581.     ' First is the DiaryIndex of the first element to be shifted.
  582.     ' Last is the DiaryIndex of the last element to be shifted.
  583.  
  584.     Dim i As Integer
  585.     
  586.     If First < 2 Then First = 2
  587.     
  588.     For i = First To Last
  589.         A(i - 1) = A(i)
  590.     Next
  591.  
  592. End Sub
  593.  
  594. Sub ShiftLeftComputer (Pos As Integer)
  595.     Dim Win As Integer
  596.     
  597.     If ComputerNo = 1 Then
  598.         Form1.Picture4(1).Visible = False
  599.         Form1.Picture4(1).Enabled = False
  600.         ComputerNo = 0
  601.         Exit Sub
  602.     End If
  603.  
  604.     For i = Pos To (ComputerNo - 1)
  605.         Form1.Picture4(i).Picture = Form1.Picture4(i + 1).Picture
  606.         Form1.Picture4(i).Tag = Form1.Picture4(i + 1).Tag
  607.     Next i
  608.     ComputerNo = ComputerNo - 1
  609.     For i = ComputerNo + 1 To 6
  610.         Form1.Picture4(i).Visible = False
  611.         Form1.Picture4(i).Enabled = False
  612.     Next i
  613.     
  614. End Sub
  615.  
  616. Sub ShiftLeftPlayer (Pos As Integer)
  617.  
  618.     Dim Win As Integer
  619.     
  620.     If PlayerNo = 1 Then
  621.         Form1.Picture2(1).Visible = False
  622.         Form1.Picture2(1).Enabled = False
  623.         PlayerNo = 0
  624.         Exit Sub
  625.     End If
  626.  
  627.     For i = Pos To (PlayerNo - 1)
  628.         Form1.Picture2(i).Picture = Form1.Picture2(i + 1).Picture
  629.         Form1.Picture2(i).Tag = Form1.Picture2(i + 1).Tag
  630.     Next i
  631.     PlayerNo = PlayerNo - 1
  632.     For i = PlayerNo + 1 To 6
  633.         Form1.Picture2(i).Visible = False
  634.         Form1.Picture2(i).Enabled = False
  635.     Next i
  636.  
  637. End Sub
  638.  
  639. Sub ShiftLeftTable (Pos As Integer)
  640.     If TableNo = 1 Then
  641.         Form1.Picture1(1).Picture = Form1.Picture1(2).Picture
  642.         Form1.Picture1(1).Tag = "End"
  643.         Form1.Picture1(2).Visible = False
  644.         Form1.Picture1(2).Enabled = False
  645.         TableNo = 0
  646.         Exit Sub
  647.     End If
  648.  
  649.     For i = Pos To TableNo
  650.         Form1.Picture1(i).Picture = Form1.Picture1(i + 1).Picture
  651.         Form1.Picture1(i).Tag = Form1.Picture1(i + 1).Tag
  652.     Next i
  653.  
  654.     Form1.Picture1(TableNo + 1).Visible = False
  655.     Form1.Picture1(TableNo + 1).Enabled = False
  656.     
  657.     
  658.     TableNo = TableNo - 1
  659.     
  660.     
  661.  
  662.  
  663.     
  664. End Sub
  665.  
  666. Sub ShiftLeftWho (Pos As Integer)
  667.     
  668.     Dim Win As Integer
  669.  
  670.     If GameSwitch = PLAYER_MOVE Then
  671.         ShiftLeftPlayer Pos
  672.     Else
  673.         ShiftLeftComputer Pos
  674.     End If
  675.  
  676.     If DealSwitch = PLAYER_DEAL Then
  677.         If PlayerNo = 0 Then
  678.             If CardNo > 52 Then
  679.                 LastPickup
  680.                 CheckFor27Cards
  681.                 Win = CheckForWin()
  682.                 If Win = True Then
  683.                     AskForNewGame
  684.                     Exit Sub
  685.                 End If
  686.                 DealSwitch = COMPUTER_DEAL
  687.                 FirstDeal
  688.             Else
  689.                 PlayerDeal
  690.                 GameSwitch = COMPUTER_MOVE
  691.                 EnableComputerMove
  692.  
  693.             End If
  694.         Else
  695.             If GameSwitch = PLAYER_MOVE Then
  696.                 GameSwitch = COMPUTER_MOVE
  697.                 EnableComputerMove
  698.             Else
  699.                 GameSwitch = PLAYER_MOVE
  700.                 EnablePlayerMove
  701.             End If
  702.         End If
  703.     Else
  704.         If ComputerNo = 0 Then
  705.             If CardNo > 52 Then
  706.                 LastPickup
  707.                 CheckFor27Cards
  708.                 Win = CheckForWin()
  709.                 If Win = True Then
  710.                     AskForNewGame
  711.                     Exit Sub
  712.                 End If
  713.                 DealSwitch = PLAYER_DEAL
  714.                 FirstDeal
  715.             Else
  716.                 ComputerDeal
  717.                 GameSwitch = PLAYER_MOVE
  718.                 EnablePlayerMove
  719.                 
  720.             End If
  721.         Else
  722.             If GameSwitch = PLAYER_MOVE Then
  723.                 GameSwitch = COMPUTER_MOVE
  724.                 EnableComputerMove
  725.             Else
  726.                 GameSwitch = PLAYER_MOVE
  727.                 EnablePlayerMove
  728.             End If
  729.         End If
  730.     End If
  731. End Sub
  732.  
  733. Sub TestAsAces (T1 As Integer, T2 As Integer, P1 As Integer, RCds As Integer, Vp As String, Flag As Integer)
  734.     If T2 = 11 Then
  735.         If P1 = T1 + 1 Then
  736.             Vp = "Y"
  737.             Flag = True
  738.             Exit Sub
  739.         End If
  740.     Else
  741.         If T1 = 11 Then
  742.             If P1 = 1 + T2 Then
  743.                 Vp = "Y"
  744.                 Flag = True
  745.                 Exit Sub
  746.             End If
  747.         Else
  748.             If T1 = 11 Then
  749.                 If T2 = 11 Then
  750.                     If P1 = 2 Then
  751.                         Vp = "Y"
  752.                         Flag = True
  753.                     End If
  754.                 End If
  755.             End If
  756.         End If
  757.     End If
  758.                    
  759.     
  760. End Sub
  761.  
  762. Sub TestPlays ()
  763.     Dim i As Integer
  764.  
  765.     Dim PlayVal As Integer
  766.     Dim RemainingCards As Integer
  767.     Dim MatchFound As Integer
  768.     Dim JackFound As Integer
  769.     
  770.  
  771.  
  772.     For i = 1 To ComputerNo
  773.  
  774.         RemainingCards = TableNo
  775.         LoadTableArray
  776.         
  777.         PlayVal = CardValue(Cards(Val(Form1.Picture4(i).Tag)))
  778.         SetNewValue PlayVal
  779.  
  780.         TestForJack PlayVal, ValidPlay(i), JackFound
  781.  
  782.         If JackFound = False Then
  783.             TestEqualRank PlayVal, ValidPlay(i), RemainingCards
  784.             TestEqualValue PlayVal, ValidPlay(i), RemainingCards
  785.         End If
  786.  
  787.         If ValidPlay(i) = "Y" Then
  788.             TestForTypeOfPlay PlayVal, ValidPlay(i), i, RemainingCards, TypeOfPlay(i)
  789.         End If
  790.  
  791.     Next i
  792.                 
  793. End Sub
  794.  
  795.